package com.l024.android_ljl.api;

import com.l024.android_ljl.constant.ApiConstant;
import com.l024.android_ljl.entity.ObjectEntity;
import com.l024.android_ljl.entity.SysCommentEntity;
import com.l024.android_ljl.entity.SysSubjectEntity;
import com.l024.android_ljl.entity.SysTypeEntity;
import com.l024.android_ljl.entity.SysUserEntity;
import com.l024.android_ljl.entity.SysUserSaveEntity;
import com.quantstack.llcommonlibrary.base.BaseHttpResult;

import java.util.List;

import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;

/**
 * @author wu_ming_zhi_bei
 * @date 2021/5/6 17:43
 * @Notes App接口
 */
public interface AppApi {
    /**
     * 登录
     * @return
     */
    @POST(ApiConstant.LOGIN)
    Observable<SysUserEntity> login(@Body RequestBody requestBody);

    /**
     * 上传文件
     * @param Body
     * @return
     */
    @POST(ApiConstant.UPLOAD_FILE)
    Observable<BaseHttpResult<ObjectEntity>> uploadFile(@Body RequestBody Body);

    /**
     * 注册
     * @return
     */
    @POST(ApiConstant.REGISTER)
    Observable<BaseHttpResult<ObjectEntity>> register(@Body RequestBody requestBody);

    /**
     * 获取所有的试题
     * @return
     */
    @GET(ApiConstant.SUBJECT_ALL)
    Observable<BaseHttpResult<List<SysSubjectEntity>>> getSubjects();

    /**
     * 获取类型下所有的试题
     * @return
     */
    @GET(ApiConstant.SUBJECT_TYPE_ALL+"/{id}")
    Observable<BaseHttpResult<List<SysSubjectEntity>>> getTypeSubjects(@Path("id") Long id);

    /**
     * 获取所有的试题
     * @return
     */
    @GET(ApiConstant.TYPE_ALL)
    Observable<BaseHttpResult<List<SysTypeEntity>>> getTypes();

    /**
     * 收藏
     * @return
     */
    @POST(ApiConstant.SAVE_SUBJECT)
    Observable<ObjectEntity> saveUserSubject(@Body RequestBody requestBody);

    /**
     * 获取用户收藏
     * @return
     */
    @GET(ApiConstant.SAVE_USER_ALL+"/{userId}")
    Observable<BaseHttpResult<List<SysUserSaveEntity>>> getUserSave(@Path("userId") Long userId);

    /**
     * 评论
     * @return
     */
    @POST(ApiConstant.SAVE_COMMENT)
    Observable<ObjectEntity> saveComment(@Body RequestBody requestBody);

    /**
     * 获取用户评论
     * @return
     */
    @GET(ApiConstant.GET_USER_COMMENTS+"/{userId}")
    Observable<BaseHttpResult<List<SysCommentEntity>>> getUserComment(@Path("userId") Long userId);

    /**
     * 获取试卷收藏
     * @return
     */
    @GET(ApiConstant.GET_SUBJECT_COMMENTS+"/{subjectId}")
    Observable<BaseHttpResult<List<SysCommentEntity>>> getSubjectComment(@Path("subjectId") Long id);

    /**
     * 搜索
     * @return
     */
    @GET(ApiConstant.SUBJECT_SEARCH+"/{key}")
    Observable<BaseHttpResult<List<SysSubjectEntity>>> searchSubject(@Path("key")String key);
}
